<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=0.5,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no, email=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <!-- 删除苹果默认的工具栏和菜单栏 -->
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <!-- 设置苹果工具栏颜色 -->
    <meta name="format-detection" content="telphone=no, email=no" />
    <!-- 忽略页面中的数字识别为电话，忽略email识别 -->
    <!-- 启用360浏览器的极速模式(webkit) -->
    <meta name="renderer" content="webkit">
    <!-- 避免IE使用兼容模式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
    <meta name="HandheldFriendly" content="true">
    <!-- 微软的老式浏览器 -->
    <meta name="MobileOptimized" content="320">
    <!-- uc强制竖屏 -->
    <meta name="screen-orientation" content="portrait">
    <!-- QQ强制竖屏 -->
    <meta name="x5-orientation" content="portrait">
    <!-- UC强制全屏 -->
    <meta name="full-screen" content="yes">
    <!-- QQ强制全屏 -->
    <meta name="x5-fullscreen" content="true">
    <!-- UC应用模式 -->
    <meta name="browsermode" content="application">
    <!-- QQ应用模式 -->
    <meta name="x5-page-mode" content="app">
    <!-- windows phone 点击无高光 -->
    <meta name="msapplication-tap-highlight" content="no">
    <title>工单管理</title>
    <link rel="stylesheet" href="{{asset('css/reset.css')}}">
    <link rel="stylesheet" href="{{asset('css/main.css')}}">
    <link rel="stylesheet" href="{{asset('css/index.css')}}">
    <link rel="stylesheet" href="{{asset('css/LCalendar.css')}}">
    <link rel="stylesheet" href="{{asset('css/yd_rl.css')}}" />
</head>
<body>
    <!-- 公共头部 -->
    <div class="g2_head-bg">
        <!-- 返回上一层 -->
        <p class="g2_head_goback-bg fl">
            <a href="javascript:history.back(-1)">
                <img src="{{asset('images/xky_icon0-1.png')}}" class="g2_head_goback_icon fl" alt="">
                <span class="g2_head_goback_del fl">返回</span>
            </a>
        </p>
        <p class="ym-tit fl">录入成交单</p>
        <span class="g2_head_goback_del fr khxz_color">新增</span>
        <span class="g2_head_goback_del fr gdlb_sx">筛选</span>
        <div class="cl"></div>
    </div>
    <div class="g2_head-bg2"></div>

    <!-- 工单（成交单）详情 -->
    <div class="gdcjd-bg">
        <form action="" id="formchengjiao">
            <!-- 客户信息（填写/查看成交单）详情 -->
            <p class="gdx2_tit">成交单信息</p>
            <ul class="grzx_xq-bg">
                <li class="grzx_xq_list">
                    <p class="grzx_xgname fl">合同类型</p>
                        <span class="sewv fr">
                            <span class="sewvtop">
                                <input type="text" id='hetongleixing' name="deal_hetongtype" style="height:12vw;border:none;font-size:1.6rem;width:88%;" value="" placeholder="请选择合同类型">
                                <em>
                                    <img src="{{asset('images/xky_icon9.png')}}">
                                </em>
                            </span>
                            <ul class="sewvbm">
                                @foreach($hetongtype as $vo)
                                    <li>{{$vo->title}}</li>
                                @endforeach
                            </ul>
                        </span>
                    <div class="cl"></div>
                </li>
                <li class="grzx_xq_list">
                    <p class="grzx_xgname fl">合同编号</p>
                        <span class="sewv fr">
                            <span class="sewvtop">
                                <input type="text" id='hetong' name="deal_hetong" style="height:12vw;border:none;font-size:1.6rem;width:88%;" value="" placeholder="请选择合同编号">
                                <em>
                                    <img src="{{asset('images/xky_icon9.png')}}">
                                </em> 
                            </span>
                            <ul class="sewvbm" id="hetonglist">
                               
                            </ul>
                        </span>
                    <div class="cl"></div>
                </li>
                <li class="grzx_xq_list">
                    <p class="grzx_xgname fl">旅游人数</p>
                    <p class="grzx_xgname_del grzx_xgsjhm-bg fr">
                         <input type="text" name="deal_num" placeholder="请填写旅游人数" class="grzx_xgsjhm" value="">
                    </p>
                    <div class="cl"></div>
                </li>
                <li class="grzx_xq_list">
                    <p class="grzx_xgname fl">应收款</p>
                    <p class="grzx_xgname_del grzx_xgsjhm-bg fr">
                         <input type="text" name="deal_yshoukuan" placeholder="请输入应收款金额" class="grzx_xgsjhm" value="">
                    </p>
                    <div class="cl"></div>
                </li>
                <li class="grzx_xq_list">
                    <p class="grzx_xgname fl">应付款</p>
                    <p class="grzx_xgname_del grzx_xgsjhm-bg fr">
                        <input type="text" name="deal_ydakuan" placeholder="请输入应付款金额" class="grzx_xgsjhm" value="">
                    </p>
                    <div class="cl"></div>
                </li>
                <li class="grzx_xq_list">
                    <p class="grzx_xgname fl">操作类别</p>
                        <span class="sewv fr" style="text-align:right;">
                            <span class="sewvtop">
                                <input type="text" name="deal_leibie" style="height:12vw;border:none;font-size:1.6rem;width:88%;" value="" placeholder="请选择操作类别">
                                <em>
                                    <img src="{{asset('images/xky_icon9.png')}}">
                                </em>
                            </span>
                            <ul class="sewvbm">
                                <li>外拼</li>
                                <li>自组</li>
                            </ul>
                        </span>
                    <div class="cl"></div>
                </li>
                <li class="grzx_xq_list">
                    <p class="grzx_xgname fl">供应商名称</p>
                    <p class="grzx_xgname_del grzx_xgsjhm-bg fr">
                        <input type="hidden" name="deal_gongyingshang" id="gongyingsahng" value="">
                        <input type="text" placeholder="请选择供应商名称" class="grzx_xgsjhm xzgys_box1" value="">
                    </p>
                    <div class="cl"></div>
                </li>
                <li class="grzx_xq_list" style="position:relative;">
                    <p class="grzx_xgname fl">出发时间</p>
                    <p class="grzx_xgname_del grzx_xgsjhm-bg fr">
                    <input type="text" name="deal_ftdate" id="start_date" class="start_date3" placeholder="请选择出发时间" style="width:46%;margin-top:3vw;border:none !important;text-align:right;" readonly="readonly" />
                    </p>
                    <div class="cl"></div>
                </li>
                <li class="grzx_xq_list">
                    <p class="grzx_xgname fl">员工姓名</p>
                    <p class="grzx_xgname_del grzx_xgsjhm-bg fr">
                        <input type="hidden" name="deal_userid" value="{{$deal_userid}}">
                        <input type="hidden" name="deal_orderid" value="{{$deal_orderid}}">
                        <input type="hidden" name="deal_customer_id" value="{{$deal_customer_id}}">
                        <input type="text" name="deal_yuangong" readonly="readonly" placeholder="请填写员工姓名" class="grzx_xgsjhm" value="{{$yuangong}}">
                    </p>
                    <div class="cl"></div>
                </li>
            </ul>
            <div style="width:100%;height:20vw;"></div>
            <!-- 按钮 -->
            <!-- 保存成交单 -->
            <input type="button" id="tijiao" class="cjd_lrbc-btn" value="保 存">
            <input type="button" onclick="javascript:history.back(-1)" class="cjd_lrqx-btn" value="取 消">
        </form>
    </div>
    <!-- 供应商多选 -->
    <div class="gysdx-bg">
        <p class="gyssx-bg">
            <input type="text" class="gyssx_box" placeholder="请输入供应商名称">
            <input type="button" class="gyssx_btn" value="搜索">
        </p>
        <ul class="gysdx-bg1">
            @foreach($gongyingshang as $vo)
            <li class="gysname_list">
                <span class="gysnamedel" myAttr="{{$vo->id}}">{{$vo->supplier_logoname}}</span>
            </li>
            @endforeach
        </ul>
        <span class="qkyxzgys_btn">清空已选择供应商</span>
        <p class="yxzgys-bg"></p>
        <input type="text" class="gysqx_btn fl" value="取 消">
        <input type="text" class="gysqd_btn fr" value="确 定">
        <div class="cl"></div>
    </div>
    <!-- 遮罩 -->
    <!-- loading 小圆圈 -->
    <div class="z2_loading-bg" style="width:100%;height:100%;background:rgba(255,255,255,0.6);position:fixed;;left:0;top:0;">
        <img src="{{asset('images/loading1.gif')}}" style="width:10%;position:fixed;left:0;right:0;top:0;bottom:0;margin:auto;" alt="">
    </div>
    <!-- loadning对号 -->
    <div class="duihao" style="width:100%;height:100%;position:fixed;;left:0;top:0;display:none;">
        <img src="{{asset('images/duihao.png')}}" style="width:10%;position:fixed;left:0;right:0;top:0;bottom:0;margin:auto;" alt="">
    </div>
    <!-- 下拉框遮罩-->
    <div class="xlz2-bg" style="width:100%;height:100%;position:fixed;left:0;top:0;background:transparent;z-index:-1;"></div>
    <!-- 提示信息 -->
    <p id="tishi" style="display:none;position:fixed;left:0;right:0;top:0;bottom:0;margin:auto;width:94%;height:8vw;line-height:8vw;color:#fff;font-size:1.6rem;text-align:center;background:rgba(0,0,0,0.5);border-radius:4px;"></p>
    
    <script src="{{asset('js/jquery.min.js')}}"></script>
    <script src="{{asset('js/fastclick.min.js')}}"></script>
</body>
    <script src="{{asset('js/LCalendar.js')}}" type="text/javascript" charset="utf-8"></script>
    <script src="{{asset('js/index.js')}}" type="text/javascript" charset="utf-8"></script>
    <script>
        $(function () {
            FastClick.attach(document.body);
        });
        window.onload = function (event) {
            $(".z2_loading-bg").hide();
        }
        $(function () {
            $("#hetong").click(function(){
                var hetongtype=$("#hetongleixing").val();
                $.ajax({
                    url:"{{url('hetongleixing')}}",
                    type:'get', //GET
                    async:false,    //或false,是否异步
                    data:{'hetongleixing':hetongtype},
                    dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                    success:function(data){ 
                        var html="";
                        $.each(data,function(i,item){
                            html+="<li>"+item+"</li>";
                    　　});
                        $("#hetonglist").html(html);
                        $("#hetonglist li").click(function(){
                            $("#hetong").val($(this).html());
                            $("#hetonglist").css('display','none');
                        })
                    }, 
                })
            })
        });
        $(function () {
            $("#tijiao").click(function(){
               if($("input[name='deal_hetongtype']").val()==''){
                    $("#tishi").html('合同类型必须选择');
                    $("#tishi").stop(true, true).fadeIn('fast');
                    $("#tishi").fadeOut(1500);
                }else if($("input[name='deal_hetong']").val()==''){
                    $("#tishi").html('合同编号必须选择');
                    $("#tishi").stop(true, true).fadeIn('fast');
                    $("#tishi").fadeOut(1500);
                }else if($("input[name='deal_num']").val()==''){
                    $("#tishi").html('旅游人数必须输入');
                    $("#tishi").stop(true, true).fadeIn('fast');
                    $("#tishi").fadeOut(1500);
                }else if($("input[name='deal_yshoukuan']").val()==''){
                    $("#tishi").html('应收款必须输入');
                    $("#tishi").stop(true, true).fadeIn('fast');
                    $("#tishi").fadeOut(1500);
                }else if($("input[name='deal_ydakuan']").val()==''){
                    $("#tishi").html('应付款必须输入');
                    $("#tishi").stop(true, true).fadeIn('fast');
                    $("#tishi").fadeOut(1500);
                }else if($("input[name='deal_leibie']").val()==''){
                    $("#tishi").html('操作类别必须选择');
                    $("#tishi").stop(true, true).fadeIn('fast');
                    $("#tishi").fadeOut(1500);
                }else if($("input[name='deal_gongyingshang']").val()==''){
                    $("#tishi").html('供应商必须选择');
                    $("#tishi").stop(true, true).fadeIn('fast');
                    $("#tishi").fadeOut(1500);
                }else if($("input[name='deal_ftdate']").val() ==''){
                    $("#tishi").html('出发时间必须输入');
                    $("#tishi").stop(true, true).fadeIn('fast');
                    $("#tishi").fadeOut(1500);
                }else{
                    var d = {};
                    var t = $('#formchengjiao').serializeArray();
                    $.each(t, function() {
                      d[this.name] = this.value;
                    });
                    var data=JSON.stringify(d);
                    $.ajax({
                        url:"{{url('chengjiao/luru')}}",
                        type:'post', 
                        async:false,    //或false,是否异步
                        data:{'_token':'{{csrf_token()}}','data':data},
                        dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                        beforeSend:function(){
                            console.log('发送前');
                            $('.z2_loading-bg').show();
                        },
                        success:function(data){
                            if(data=="false"){
                                $('.z2_loading-bg').hide();
                                $("#tishi").html('录入失败');
                                $("#tishi").stop(true, true).fadeIn('fast');
                                $("#tishi").fadeOut(1500);
                            }else{
                                $('.z2_loading-bg').hide();
                                $('.duihao').show();
                                $('.duihao').hide(1000);
                                $(location).attr('href', "{{url('chengjiao')}}/"+data);
                            }
                        }, 
                    })
                } 
            })
        });


        // 供应商选择
        $('.xzgys_box1').click(function(){
            $('.gysdx-bg').fadeIn(200);
        })

        var gsyname_del='';
        var gysxzjg='';
        var myAttr='';
        $('.gysname_list').click(function(){
            // alert($(this).html());
            // $(this).parent().children().eq(0).attr('checked',true);
            $(this).css('background','#eee');
            $(this).children().eq(1).html();
            var name_del= $(this).children().eq(0).html();
            var name_attr=$(this).children().eq(0).attr('myAttr');
            // console.log($(this).children().eq(0).html());
            gsyname_del="<span class='gysyxz_listxq' style='display:inline-block;padding:0 2% 0 2%;height:8vw;text-align:center;line-height:8vw;font-size:1.6rem;background:#3c8dbc;color:#fff;border-radius:4px;margin:1vw 0 0 2%;overflow:hidden;position:relative;'>"+ name_del +"</span>" ;
            // console.log(gsyname_del);
            gysxzjg+= name_del+',';
            myAttr+=name_attr+',';
            var cfgys_box='';
            cfgys_box+= gsyname_del;
            console.log(cfgys_box);
            $('.yxzgys-bg').append(cfgys_box);
        })
        $('.gysqd_btn').click(function(){
            $('.gysdx-bg').fadeOut(500);
            $('.xzgys_box1').val(gysxzjg);
            $('#gongyingsahng').val(myAttr);
        })
        // 清空已经选择的供应商
        $('.qkyxzgys_btn').click(function(){
            $('.yxzgys-bg').children().remove();
            $('.gysname_list').css('background','#fff');
            gysxzjg='';
            myAttr='';
            $('.xzgys_box1').val('');
            $('#gongyingsahng').val('');
        })
        // 取消选择供应商
        $('.gysqx_btn').click(function(){
            $('.gysdx-bg').fadeOut(500);
        })


    </script>
    <script type="text/javascript">
        var calendar = new LCalendar();
        calendar.init({
            'trigger': '#start_date', //标签id
            'type': 'date', //date 调出日期选择 datetime 调出日期时间选择 time 调出时间选择 ym 调出年月选择,
            'minDate': (new Date().getFullYear() - 3) + '-' + 1 + '-' + 1, //最小日期
            'maxDate': (new Date().getFullYear() + 3) + '-' + 12 + '-' + 31 //最大日期
        });

        var calendar = new LCalendar();
        calendar.init({
            'trigger': '#end_date', //标签id
            'type': 'date', //date 调出日期选择 datetime 调出日期时间选择 time 调出时间选择 ym 调出年月选择,
            'minDate': (new Date().getFullYear() - 3) + '-' + 1 + '-' + 1, //最小日期
            'maxDate': (new Date().getFullYear() + 3) + '-' + 12 + '-' + 31 //最大日期
        });
                //      $(function() {
                //          $('#start_date').date();
                //          $('#end_date').date();
                //      });
    $('.date_btn').click(function () {
        alert(111);
        $('.grzx_xgdate').css('display', 'block');
    })

    </script>
</html>